Load session using cabal's --with-repl command #466
Merged
fendor merged 5 commits intohaskell:masterfrom Jul 8, 2025
Merged
Conversation
6 tasks
9a7930a to
a472c08
Compare
a472c08 to
4d397da
Compare
7e539c5 to
dc8e137
Compare
mpickering
approved these changes
Jul 7, 2025
Collaborator
mpickering
left a comment
There was a problem hiding this comment.
Looks fine to me in general, but I am not very familiar with this code and it changes many lines.
Is the approach load out somewhere in a Note? it would be good to precise explain at which cabal version this logic can be dropped.
This avoids quite a lot of hacky implementations to find the correct GHC
version, libdir and ghc-pkg location, as well as global package db
stuff.
There is a corner case which we need to handle:
```
cabal >= 3.15 && lib:Cabal <3.15
```
In other words, when a custom-setup imposes a restriction on the
`lib:Cabal` version, and this `lib:Cabal` version doesn't support the
`--with-repl` flag, then we can't use `--with-repl`.
We detect this by looking at the error message of the cabal command, it
looks roughly like this:
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-with-custom-setup-0.1.0.0 (user goal)
[__1] next goal: cabal-with-custom-setup:setup.Cabal (dependency of cabal-with-custom-setup)
[__1] rejecting: cabal-with-custom-setup:setup.Cabal; 3.10.3.0/installed-3.10.3.0, ... (constraint from --with-repl requires >=3.15)
...
We check the error message for the existence of `constraint from
--with-repl requires >=3.15` and then fall back to using the old
approach which doesn't use response files or `--with-repl` flag.
Additionally, we extract a new `Process` module which contains helpers
for cradle actions.
Cradle.hs grew a lot and is becoming to be unwieldy. We fix this by extracting the most complicated cradle (cabal) into a separate module. To make this possible, we had to additionally extract a couple of types and functions into separate modules as well to avoid cyclic module dependencies. This commit should not change any behaviour, but merely adds documentation and moves definitions and data types.
e312772 to
e54869d
Compare
Collaborator
Author
|
I have added a note which explains the current approach in detail! Thank you for your review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This avoids quite a lot of hacky implementations to find the correct GHC
version, libdir and ghc-pkg location, as well as global package db
stuff.
There is a corner case which we need to handle:
In other words, when a custom-setup imposes a restriction on the
lib:Cabalversion, and thislib:Cabalversion doesn't support the--with-replflag, then we can't use--with-repl.We detect this by looking at the error message of the cabal command, it
looks roughly like this:
We check the error message for the existence of
constraint from --with-repl requires >=3.15and then fall back to using the oldapproach which doesn't use response files or
--with-replflag.Additionally, we extract a new
Processmodule which contains helpersfor cradle actions.
closes #467